import net.sf.json.JSONObject;

/**
 * Created by xps-13 on 2017/1/5.
 */
public class ReadJson {
    //解析json字符串的类
    public static void ReadJson(String jsonString) {

        JSONObject j = JSONObject.fromObject(jsonString);

        // 循环添加Information对象
        for (int i = 0; i < 20; i++) {
            Information information = new Information();
            Database db = new Database();
            information.setAvnumber(j.getJSONObject("data").getJSONObject("archives").getJSONObject(String.valueOf(i)).getString("aid").toString());
            information.setCreator(j.getJSONObject("data").getJSONObject("archives").getJSONObject(String.valueOf(i)).getString("author").toString());
            information.setCategory(j.getJSONObject("data").getJSONObject("archives").getJSONObject(String.valueOf(i)).getString("tname").toString());
            information.setCoin(j.getJSONObject("data").getJSONObject("archives").getJSONObject(String.valueOf(i)).getJSONObject("stat").getInt("coin"));
            information.setCollections(j.getJSONObject("data").getJSONObject("archives").getJSONObject(String.valueOf(i)).getInt("favorites"));
            db.setInformation(information);

        }
    }
}
